﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;

namespace DichVuQuan4
{
    public partial class _Default : System.Web.UI.Page
    {
        //public string keyword = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (Request.QueryString["trang"] != null)
            //{
            //    string page = Request.QueryString["trang"];
            //    DataTable dt = (DataTable)Session["data"];
            //    //Response.Redirect("Default.aspx?trang=" + page);
            //    DataTable temp = getPage(dt, 8, 2);
            //    Response.Write(returnCodeHTML(temp));
            //}

            //keyword = Request.QueryString["keyword"];

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private string returnCodeHTML(DataTable dt)
        {
            string strHTML = "<ul>";

            for (int i = 0; i < dt.Rows.Count; i++)
            {

                string TenDiaDiem = dt.Rows[i]["TenDiaDiem"].ToString();
                string TenDuong = dt.Rows[i]["TenDuong"].ToString();
                string TenPhuong = dt.Rows[i]["TenPhuong"].ToString();
                string TenQuanHuyen = dt.Rows[i]["TenQuanHuyen"].ToString();

                strHTML += "<li onclick=\"set_map(" + dt.Rows[i]["ViDo"].ToString() + "," + dt.Rows[i]["KinhDo"].ToString() + "," + "'" + TenDiaDiem + "');\">";
                strHTML += "<strong>" + TenDiaDiem + "</strong><br />";
                strHTML += "<small>" + dt.Rows[i]["SoNha"].ToString() + " " + TenDuong + ", Phường " + TenPhuong + ", Quận " + TenQuanHuyen + "</small><br />";
                //strHTML += "<small>" + dt.Rows[i]["ChuThich"].ToString() + "</small>";
                strHTML += "</li>";
            }
            strHTML += "</ul>";
            return strHTML;
        }

        private DataTable getPage(DataTable curentDatatable, int skip, int page)
        {
            DataTable dt = null;
            int getTo = page * 8;
            dt = curentDatatable.AsEnumerable().Skip(skip).Take(getTo).CopyToDataTable();
            return dt;
        }
    }
}
